<template>
  <fieldset>
    <legend>商品列表</legend>
    <ul>
      <li v-for="item in list" :key="item._id" @click="goDetail(item)">
        {{ item.productName }}
      </li>
    </ul>
  </fieldset>
</template>

<script>
export default {
  data() {
    return {
      list: []
    }
  },
  mounted() {
    fetch("http://chst.vip:1234/api/getmoneyctrl")
      .then((a) => a.json())
      .then((res) => {
        console.log(res)
        this.list = res.result
      })
  },
  methods: {
    goDetail(item) {
      this.$router.push({
        name: "yang",
        query: { id: item.productId },
        params: { id: item.productId }
      })
    }
  }
}
</script>
